<?php

namespace app\api\controller;
use app\common\controller\Api;
use think\Log;

/**
 * 首页接口
 */
class Index extends Api
{

    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function index()
    {
        $dataStr = file_get_contents('php://input');
        $data = json_decode($dataStr,true);
        $map['press'] = $data['press'];

        $map['addtime'] = date('Y-m-d H:i:s');
        if($map['press']==1 ){
            if(  $map['addtime'] < date("Y-m-d")." ".config('work_time')){
                $map['status'] =1;
            }else{
                $map['status'] =2;
            }
        }

        if($map['press']==2){
            if(   date("Y-m-d")." 14:00:00" < $map['addtime'] && $map['addtime'] < date("Y-m-d")." ".config('out_time') ){
                $map['status'] =3;
            }else{
                $map['status'] =4;
            }
        }

        $map['userid'] = isset($data1['userid']) ? $data['userid'] : 2;
        $map['username'] =  db('admin')->find($map['userid'])['username'];
        $data1['mq'] = $data['mq'];
        $data1['addtime'] = date('Y-m-d H:i:s');
        if(  $map['press']){
            db('time')->insert($map);
        }

        db('mq')->insert($data1);
        Log::log($data);
        echo '';exit;
    }
    public function index2()
    {
        $dataStr = file_get_contents('php://input');
        $data['dataOne'] = json_encode($dataStr);
        $data['dataTwo'] = input('post.');
        if(empty($data['dataOne'])&&$data['dataOne']){
            echo 'NOT DATA'; exit;
        }
        Log::log($data);
        $this->success('请求成功',$data);
    }

}
